package com.wholesale.beans;

import org.json.JSONException;
import org.json.JSONObject;

public class UserInfo {

	private int addressId ;
	private String alias ;
	private String birthday ;
	private String country ;
	private String email ;
	private double frozenMoney ;
	private String homePhone ;
	private String lastIp ;
	private String lastLogin ;
	private String mobliePhone ;
	private String msn ;
	private String officePhone ;
	private int parentId ;
	private long payPoints ;
	private String qq ;
	private int rankPoints ;
	private String regTime ;
	private int sex ;
	private String skype ;
	private int userId ;
	private double userMoney ;
	private String userName ;
	private String yahoo ;
	private JSONObject jsonObject;
	public int getAddressId() {
		return addressId;
	}
	public void setAddressId(int addressId) {
		this.addressId = addressId;
	}
	public String getAlias() {
		return alias;
	}
	public void setAlias(String alias) {
		this.alias = alias;
	}
	public String getBirthday() {
		return birthday;
	}
	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}
	public String getCountry() {
		return country;
	}
	public void setCountry(String country) {
		this.country = country;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public double getFrozenMoney() {
		return frozenMoney;
	}
	public void setFrozenMoney(double frozenMoney) {
		this.frozenMoney = frozenMoney;
	}
	public String getHomePhone() {
		return homePhone;
	}
	public void setHomePhone(String homePhone) {
		this.homePhone = homePhone;
	}
	public String getLastIp() {
		return lastIp;
	}
	public void setLastIp(String lastIp) {
		this.lastIp = lastIp;
	}
	public String getLastLogin() {
		return lastLogin;
	}
	public void setLastLogin(String lastLogin) {
		this.lastLogin = lastLogin;
	}
	public String getMobliePhone() {
		return mobliePhone;
	}
	public void setMobliePhone(String mobliePhone) {
		this.mobliePhone = mobliePhone;
	}
	public String getMsn() {
		return msn;
	}
	public void setMsn(String msn) {
		this.msn = msn;
	}
	public String getOfficePhone() {
		return officePhone;
	}
	public void setOfficePhone(String officePhone) {
		this.officePhone = officePhone;
	}
	public int getParentId() {
		return parentId;
	}
	public void setParentId(int parentId) {
		this.parentId = parentId;
	}
	public long getPayPoints() {
		return payPoints;
	}
	public void setPayPoints(long payPoints) {
		this.payPoints = payPoints;
	}
	public String getQq() {
		return qq;
	}
	public void setQq(String qq) {
		this.qq = qq;
	}
	public int getRankPoints() {
		return rankPoints;
	}
	public void setRankPoints(int rankPoints) {
		this.rankPoints = rankPoints;
	}
	public String getRegTime() {
		return regTime;
	}
	public void setRegTime(String regTime) {
		this.regTime = regTime;
	}
	public int getSex() {
		return sex;
	}
	public void setSex(int sex) {
		this.sex = sex;
	}
	public String getSkype() {
		return skype;
	}
	public void setSkype(String skype) {
		this.skype = skype;
	}
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public double getUserMoney() {
		return userMoney;
	}
	public void setUserMoney(double userMoney) {
		this.userMoney = userMoney;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getYahoo() {
		return yahoo;
	}
	public void setYahoo(String yahoo) {
		this.yahoo = yahoo;
	}
	
	public String toJsonString(){
		JSONObject loginObject = new JSONObject();
		try {
			loginObject.put("userId", userId);
			loginObject.put("email", email);
			loginObject.put("userName", userName);
			loginObject.put("sex", sex);
			loginObject.put("birthday", birthday);
			loginObject.put("userMoney", userMoney);
			loginObject.put("frozenMoney", frozenMoney);
			loginObject.put("payPoints", payPoints);
			loginObject.put("rankPoints", rankPoints);
			loginObject.put("addressId", addressId);
			loginObject.put("regTime", regTime);
			loginObject.put("lastLogin", lastLogin);
			loginObject.put("lastIp", lastIp);
			loginObject.put("alias", alias);
			loginObject.put("msn", msn);
			loginObject.put("qq", qq);
			loginObject.put("officePhone", officePhone);
			loginObject.put("homePhone", homePhone);
			loginObject.put("parentId", parentId);
			loginObject.put("mobliePhone", mobliePhone);
			loginObject.put("yahoo", yahoo);
			loginObject.put("skype", skype);
			loginObject.put("country", country);
		} catch (Exception e) {
		}
		return loginObject.toString();
	}
	
	public void jsonAnalytic(String jsonString){
		
		try {
			jsonObject = new JSONObject(jsonString);
			jsonAnalytic(jsonObject);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void jsonAnalytic(JSONObject jsonObject){
		this.jsonObject = jsonObject;
		
			try {
				userId = jsonObject.getInt("userId");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				email = jsonObject.getString("email");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				userName = jsonObject.getString("userName");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				sex = jsonObject.getInt("sex");
			} catch (JSONException e) {
				e.printStackTrace();
			}
//			birthday = new String();
//			birthday.setTime(birthday.parse(jsonObject.getString("birthday")));
			try {
				userMoney = jsonObject.getDouble("userMoney");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				frozenMoney = jsonObject.getDouble("frozenMoney");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				payPoints = jsonObject.getLong("payPoints");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				rankPoints = jsonObject.getInt("rankPoints");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				addressId = jsonObject.getInt("addressId");
			} catch (JSONException e) {
				e.printStackTrace();
			}
//			regTime = new String();
//			regTime.setTime(regTime.parse(jsonObject.getString("regTime")));
//			lastLogin = new String();
//			lastLogin.setTime(lastLogin.parse(jsonObject.getString("lastLogin")));
//			lastIp = jsonObject.getString("lastIp");
			try {
				alias = jsonObject.getString("alias");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				msn = jsonObject.getString("msn");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				qq = jsonObject.getString("qq");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				officePhone = jsonObject.getString("officePhone");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				homePhone = jsonObject.getString("homePhone");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				parentId = jsonObject.getInt("parentId");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				mobliePhone = jsonObject.getString("mobliePhone");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				yahoo = jsonObject.getString("yahoo");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				skype = jsonObject.getString("skype");
			} catch (JSONException e) {
				e.printStackTrace();
			}
			try {
				country = jsonObject.getString("country");
			} catch (JSONException e) {
				e.printStackTrace();
			}
		
	}
}
